<template>
	<view style="background-color: #edf1f4">
		 <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
		<view class="Item"style="margin-top: 30rpx;">
			<view class="item-link item-content">
				<!--<div class="item-media"></div>
				<view style="position:absolute;margin-left: 91%;margin-top:260rpx;">
					<image :src="srcsys" class="item-icon-sys" mode="" @tap="signscanCode"></image>
				</view>-->
				<view class="item-inner">
					<view class="item-title-row"style="background-color: #6D8AF9;border: 0px red solid;
					height:130rpx;color: #fff;border-radius: 20rpx;">
						<view class="item-title" style="float: left;color: #fff">{{model.资产名称}}</view>
						<view style="float: left;width: 45%;
						font-size: 30rpx;height: 80rpx;line-height: 80rpx;
						text-align: right;"
						@tap="isanAsset($event)" :data-id="model.assetId"
						>
						<view style="float: right;margin-right: 20rpx;">查看详情></view>
						<view style="float: right;margin-right: 10rpx;background-color: #fff;
						color:#6D8AF9;height: 40rpx;line-height: 40rpx;text-align: center;
						width: 80rpx;border-radius: 10rpx;margin-top: 20rpx;font-size: 25rpx;">在用</view>		
						</view>
						<view class="item-title" style="float: left;color: #fff;margin-top: -25rpx;
						">{{assetCodeTitle}}</view>
					</view>
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">使用部门：</view><view class="span">{{model.使用部门}}</view>
					</view>
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">使用人：</view><view class="span">{{model.使用人}}</view>
					</view>
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">资产位置：</view><view class="span">{{model.资产位置}}</view>
					</view>
					<view class="item-text">
							<view class="ispan" style="color:#6D8AF9 !important;font-weight: bold;"><image class="item-icon-bt" mode="">盘点信息</view>
					</view>
					<view class="item-text">
						<view class="ispan"><image  class="item-icon-bt" mode=""></image>盘点人</view>
						<view class="span">{{CurrentUserName}}</view>
					</view>
					<view v-if="model.盘点状态=='已盘'">
						<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode=""></image>盘点日期</view>
							<view class="span">{{getDateDayStr(model.盘点日期)}}</view>
						</view>
					</view>
					<view v-else>
						<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode=""></image>盘点日期</view>
							<view class="span">{{stockDate}}</view>
						</view>
					</view>
				
					<view class="item-text">
						<view class="ispan"><image class="item-icon-bt" mode=""></image>资产类别</view>
						<view class="span">{{model.资产类别}}</view>
					</view>
					<view class="item-text">
						<view class="ispan"><image class="item-icon-bt" mode=""></image>资产名称</view>
						<view class="span">{{model.资产名称}}</view>
					</view>					
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">规格型号：</view><view class="span">{{model.规格型号}}</view>
					</view>
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">数量：</view><view class="span">{{model.数量}}</view>
					</view>
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">盘点位置：</view><view class="span">{{CurrentStoreName}}</view>
					</view>
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">实际使用人：</view><view class="span">
							<input type="text"@input="onDescKeyInput" v-model="assetUsingName" placeholder="请输入实际使用人" placeholder-class="inputff"/>
							</view>
					</view>
					
					<view class="item-text">
							<view class="ispan"><image :src="scrbt" class="item-icon-bt" mode=""></image>盘点状态：</view><view class="span">
								
									 <view class="uni-input">{{statuArray[statuindex]}}</view>
								
							</view>
					</view>
					<view v-if="statuindex==1">
						<view class="item-text">
								<view class="ispan"><image :src="scrbt" class="item-icon-bt" mode=""></image>异常类型：</view>
								<view class="span">
								
									 <view class="uni-input">{{statuResultArray[statuResultindex]}}</view>
								
								</view>
						</view>
					</view>
					<view class="item-text">
							<view class="ispan"><image class="item-icon-bt" mode="">盘点备注：</view>
							<view class="span">
							<input type="text" v-model="assetDescription" placeholder="请输入盘点备注信息"
							 placeholder-class="inputff"/>
							</view>
					</view>
					<view class="item-text"
					 style="height: 210rpx;margin-top:80rpx !important;background-color: #fff;">
						<view class="ispan"><image :src="getbt()" class="item-icon-bt" mode=""></image>盘点照片：</view>
						<view class="span">
							
							<image :src="getvalues()" class="item-icon" 
							mode="" @tap="uploadimg()"></image>
						</view>		
					</view>
				</view>
				
			</view>
		</view>
		</mescroll-body>
		<aui-dialog ref="dialog" :title="auiDialog.title" :msg="auiDialog.msg" :btns="auiDialog.btns"
			:mask="auiDialog.mask" :maskTapClose="auiDialog.maskTapClose" :items="auiDialog.items"
			:theme="auiDialog.theme" @callback="dialogCallback"></aui-dialog>
	</view>
</template>

<script>
	import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
	import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
	import {openComDB,executeSQL,dropSQL} from "@/pages/API/sqllite/sqllite.js";
	import auiDialog from '@/components/aui-dialog/aui-dialog.vue';
	var self;
	export default {
		mixins: [MescrollMixin], // 使用mixin
		components: {
						MescrollBody
						,
						MescrollUni,
						auiDialog,
					},
		data() {
			return {
				downOption: {
					native:false,
					beforeEndDownScroll: 1000,
					textInOffset:"下拉刷新",
					textOutOffset:"释放刷新",
					textLoading:"加载中..."
					},
				// 上拉加载的配置(可选, 绝大部分情况无需配置)
				upOption: {
					page: {
						size: 6 // 每页数据的数量,默认10
					},
					noMoreSize: 3, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					},
					toTop:{
						src: "../../static/images/totop.png",
						offset : 50,
						duration : 300,
						zIndex: 9990,
						right: 20,
						bottom: 120,
						safearea: false,
						width: 72,
						radius: "50%",
						left: null
					},
				},
				model: {},
				omodel: {},
				documentmodel:{},
				loginName: "",
				loginid: "",
				loginorgId:"",
				currAddress: "上海市",
				DocumentId: "",
				AssetCode: "",
				images: [],
				srcstring: "../../static/images/icon-paizhao.png",
				srcsys: "../../static/images/icon-sys-hui.png",
				scrbt:"../../static/images/icon-bitian.png",
				assetCode:"",
				assetCodeTitle:"",
				stockDate:"确认盘点后自动更新",
				optiontype:"0",
				storeId:"",
				storeName:"",
				statuArray: ['正常', '异常'],
				statuResultArray: ['位置异常','使用人异常'],
				statuindex:0,
				statuResultindex:0,
				statuResult: '',
				assetDescription:"",
				assetUsingName:"",
				CurrentUserName:"",
				CurrentUserRoleName:"",
				CurrentDepartmentName:"",
				CurrentStoreName:"",
				CurrentStoreId:"",
				curroldpdjg:"",
				uploadloding:false,
				auiDialog: {
					title: '',
					msg: '',
					btns: [{
						name: '确定'
					}],
					mask: true,
					maskTapClose: true,
					items: [],
					theme: 1,
				},
				my_newDataObj:{},
				mystr1:"",
				mynewDocumentId:"",
				isPhoto:"",
				isrequest:true,
			}
		},
		onBackPress(options) {
			
			uni.navigateTo({
				url: '../stock/StockDocumentDetail?id=' + this.mynewDocumentId,
				animationType: 'slide-in-left',
				animationDuration: 400
			});
			return true;
		 }, 
		onNavigationBarButtonTap() {
			{
				self=this;
				const newDocumentId = uni.getStorageSync('DocumentId');
				const userdata = uni.getStorageSync('userInfo');
				uni.setStorage({
					key:"shuaxinDate",
					data:"1"
				});
				var currtime = (self.getDateDay());
			
				if(this.assetCode==""){
					uni.showModal({
							 title: '提示',
							content: '请输入资产编码或扫描',
							showCancel:false,          
							 success: function (res) {
							if (res.confirm) {
												                              
							 }
						  }
					});
					return;
					
				}else if(this.assetCode!=this.assetCodeTitle){
					uni.showModal({
							 title: '提示',
							content: '输入资产编码跟盘点资产编码不匹配，请确认',
							showCancel:false,          
							 success: function (res) {
							if (res.confirm) {
												                              
							 }
						  }
					});
					return;
				}else{						
						
						var _newDataArr = [];
						var _newDataObj = {};
						
						_newDataObj['id'] = self.model.id;
						_newDataObj['assetId'] = self.model['assetId'];
						_newDataObj['assetCode'] =self.model['assetCode'];
						_newDataObj['checkPosition'] =self.CurrentStoreId;					
						//_newDataObj['checkUser'] = self.loginName;
						//_newDataObj['checkUserOrgId'] = self.loginName;
						_newDataObj['checkResult'] = self.statuArray[self.statuindex];
						_newDataObj['checkDate'] = self.getDateDay();						
						_newDataObj['checkDescription'] = self.assetDescription;
						_newDataObj['checkAccount'] = self.model["数量"];
						_newDataObj['documentId'] =newDocumentId;
						_newDataObj['realityCheckUser'] = self.loginid;//实际盘点人ID
						_newDataObj['realityCheckUserOrgId'] = self.loginorgId;//实际盘点人部门ID
						_newDataObj['realityUsingUser'] = self.assetUsingName;//实际使用人
						_newDataArr.push(_newDataObj);
						if (_newDataObj['checkResult'].indexOf("正常") != -1) {
							_newDataObj['checkResult'] = "1";
						} else if (_newDataObj['checkResult'].indexOf("未盘") != -1) {
							_newDataObj['checkResult'] = "0";
						}else if (_newDataObj['checkResult'].indexOf("异常") != -1) {
							_newDataObj['checkResult'] = "2";
						}else if(_newDataObj['checkResult']==""){
							_newDataObj['checkResult'] = "2";
						}
						console.log(self.srcstring);
						if(self.srcstring!="../../static/images/icon-paizhao.png"){
							_newDataObj['attachFiles'] = self.srcstring;
						}else{
							if(this.isPhoto=="1"){
								uni.showToast({
									icon: 'none',
									title: '请上传盘点图片'
								});
								return;
							}
						}
						var str1 = JSON.stringify(_newDataArr);
						console.log(_newDataArr);
				
						
						this.request_tool({
							url:'/app/v1/assetCheck/checkHandleAsset',
							type:'POST',
							data:_newDataArr
						}).then(res => {
									console.error(res);
									if (res.data.code == 2000) {
										uni.navigateTo({
											url: '../stock/StockDocumentDetail?id=' + newDocumentId,
											animationType:'slide-in-left',
											    animationDuration: 500
										});		
										
										}else{
											uni.showModal({
											  title: '保存失败',
											  content:res.data.msg,
											  showCancel: false
											});
										}
									}).catch(err => {
							  console.error(err);
							  
							});
						
						
						///app/v1/assetCheck/checkHandleAsset
						
				
						
						
						
						
						
					}
		
			}
		},
		onLoad(options) {
			//首先将实例指针保存到全局变量 self 方便在异步请求中访问实例本身
			self = this;
			const newDocumentId = uni.getStorageSync('DocumentId');
			const userinfo = uni.getStorageSync("userInfo");
			self.optiontype=options.type;
			console.log(JSON.parse(userinfo));
			this.loginid=JSON.parse(userinfo).id;
			this.loginorgId=JSON.parse(userinfo).orgId;
			this.loginName = JSON.parse(userinfo).userName;
			this.CurrentUserName= JSON.parse(userinfo).userName;
			console.log(options.type);
			if(options.AssetCode!=undefined){
				
			uni.setStorage({
				key: 'AssetCode',
				data: options.AssetCode
			});
			self.assetCode=options.AssetCode;
			self.CurrentStoreId=uni.getStorageSync("CurrStore");
			self.CurrentStoreName=uni.getStorageSync("CurrStoreName");
			this.DocumentId = newDocumentId;
			let StockDocument = uni.getStorageSync("StockDocument");
			self.documentmodel=JSON.parse(StockDocument);
		  let querydata={
		  		"pageSize": 10,
		  		"current": 1,
		  		manageUser:JSON.parse(userinfo).id,
		  		queryDocumentIds:[self.documentmodel.id],
		  		assetCode:options.AssetCode,
		  	};
			console.log(querydata);
		   this.requeststo_tool({
		   	url:'/app/v1/assetCheck/getCheckDetailPageData',
		   	type:'POST', 
		   	data:querydata
		   }).then(res2 => {
		   	console.log(res2);		
		   		
					if (res2.data.code == 2000) {
							console.log(2222);	
						let list=res2.data.data.records;
						console.log(list);	
						var mydata = list;
						for (var i = 0; i < list.length; i++) {
							var datarow=list[i];
							self.model = datarow;
							if (options.type == "1") {
								self.assetCode=self.model.assetCode;
								self.assetCodeTitle=self.model.assetCode;
								self.model["资产名称"]=self.model.assetName;
								self.model["规格型号"]=self.model.model;
								self.model["数量"]=self.model.assetCount;
								self.model["使用部门"]=self.model.usingOrgName;
								self.model["使用人"]=self.model.usingUserName;
								self.model["资产位置"]=self.model.assetPositionName;
								self.model["资产类别"]=self.model.assetCategoryName;
								self.stockDate=self.model.checkDate;
								//checkDate
								self.assetDescription=self.model.checkDescription;
								self.assetUsingName=self.model.realityUsingUser;
								//realityUsingUser
								self.statuindex=1;
															
								
								if(datarow["checkResult"]=="异常"){
								   self.statuindex=1;
								   if(datarow["checkDescription"]=="位置异常"){
									   self.statuResultindex=0;
								   }else  if(datarow["checkDescription"]=="使用人异常"){
									   self.statuResultindex=1;
								   }
									//盘点备注信息
								}
								if(datarow["checkResult"]=="盘亏"){
									self.statuindex=3;
								}
								if(datarow["checkResult"]=="盘盈"){
									self.statuindex=4;
								}
								if(datarow["checkResult"]=="正常"){
										
								}
								if(datarow["assetPosition"]==self.CurrentStoreId){
									self.statuindex=0;
								}else{
									self.statuindex=1;
									self.statuResult="位置异常";
									if(self.assetDescription==null || self.assetDescription==""){
										self.assetDescription="位置异常";
									}else{
										if(self.assetDescription.indexOf("使用人异常")>-1){
											self.statuResultindex=1;
										}else if(self.assetDescription.indexOf("位置异常")>-1){
											self.statuResultindex=0;
										}
										
									}
								}
								self.curroldpdjg=datarow["checkResult"];
							}else{
								
								self.model.规格型号=self.model.model;
								self.assetCodeTitle=self.model.assetCode;
								if(datarow["assetPosition"]==self.CurrentStoreId){
									self.statuindex=0;
								}else{
									self.statuindex=1;
									self.statuResult="位置异常";
									if(self.assetDescription==null || self.assetDescription==""){
										self.assetDescription="位置异常";
									}else{
										if(self.assetDescription.indexOf("使用人异常")>-1){
											self.statuResultindex=1;
										}else if(self.assetDescription.indexOf("位置异常")>-1){
											self.statuResultindex=0;
										}
										
									}
								}
								self.curroldpdjg=datarow["checkResult"];
							}
							//self.srcstring
								let imgurl=	datarow["attachFiles"];
								if(imgurl!=null && imgurl!=""){
									self.srcstring=imgurl;
								}
								self.isPhoto=	datarow["isPhoto"];
															
						}
							self.mescroll.endSuccess(mydata.length);
							//设置列表数据
							self.goods = self.goods.concat(mydata); //追加新数据
							setTimeout(() => {
								self.mescroll.endSuccess(mydata.length)
							}, 20)
					}else{
						
							self.mescroll.endSuccess(0);
								//设置列表数据
							self.goods = []; //追加新数据
								setTimeout(() => {
							self.mescroll.endSuccess(0)
								}, 20)
												
						
					}
					console.log(77777);	
					
				
		   }).catch(err => {
		     
		     
		   });
			
			
			
			/*
			var sql2="select * from buildDetailTable where 1=1 and DocumentId='"+newDocumentId+"' and Code='"+options.AssetCode+"'";
			executeSQL('nfc', sql2, res => {
				//this.productList = mydata;
				// 接口返回的当前页数据列表 (数组)
				console.log(res);
				if(res.code!=-1404){
					var mydata = [];
					for (var i = 0; i < res.length; i++) {
						var datarow=res[i];
						self.model = datarow;
						if (options.type == "1") {
							self.assetCode=self.model.资产编码;
							self.assetCodeTitle=self.model.资产编码;
							self.model.资产名称=self.model.资产名称;
							self.model.规格型号=self.model.规格型号;
							self.model.数量=self.model.数量;
							self.model.使用部门=self.model.使用部门;
							self.model.使用人=self.model.使用人;
							self.model.资产位置=self.model.资产位置;
							self.statuindex=1;
														
							
							if(datarow["盘点结果"]=="异常"){
							   self.statuindex=2;
							   if(datarow["盘点备注信息"]=="位置异常"){
								   self.statuResultindex=0;
							   }
								//盘点备注信息
							}
							if(datarow["盘点结果"]=="盘亏"){
								self.statuindex=3;
							}
							if(datarow["盘点结果"]=="盘盈"){
								self.statuindex=4;
							}
							if(datarow["盘点结果"]=="正常"){
									
							}
							self.curroldpdjg=datarow["盘点结果"];
						}else{
							
							self.model.规格型号=self.model.规格型号;
							self.assetCodeTitle=self.model.资产编码;
							if(datarow["StorePlaceId"].toString()==self.CurrentStoreId){
								self.statuindex=0;
							}else{
								self.statuindex=1;
								self.statuResult="位置异常";
								self.assetDescription="位置异常";
							}
							self.curroldpdjg=datarow["盘点结果"];
						}
						//self.srcstring
							let imgurl=	datarow["ImgUrl"];
							if(imgurl!=null && imgurl!=""){
								self.srcstring=imgurl;
							}
							self.isPhoto=	datarow["isPhoto"];
														
					}
						self.mescroll.endSuccess(mydata.length);
						//设置列表数据
						self.goods = self.goods.concat(mydata); //追加新数据
						setTimeout(() => {
							self.mescroll.endSuccess(mydata.length)
						}, 20)
					}else{												
						self.mescroll.endSuccess(0);
							//设置列表数据
						self.goods = []; //追加新数据
							setTimeout(() => {
						self.mescroll.endSuccess(0)
							}, 20)
											
					}
				
			});*/
			
			
			
			
			
			
			}else{
			
			}

			
		},
		methods: {
			getbt(){
				if(this.isPhoto=="1"){
					return this.scrbt;
				}else{
					return "";
					}
					
				
			},
			getvalues(){
				
					//console.log('https://app.ztlib.com:9000/'+value[0].realUrl);
					if(this.srcstring=="../../static/images/icon-paizhao.png"){
						return this.srcstring;
					}else{
						if(this.srcstring.indexOf("gdzcfile")>-1){
							return uni.getStorageSync("localurlfileurl")+this.srcstring;
						}else{
							return this.srcstring;
						}
					}
					
				
			},
			uploadimg() {
				self = this;
				if(self.uploadloding==true){
					return;
				}
				self.uploadloding=true;
				// 只允许通过相机扫码
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'],
					sourceType: ['camera'],
					success: function(res) {
						const tempFilePaths = res.tempFilePaths;
						const filePath = tempFilePaths[0];
						
						console.log(res.tempFiles[0]);
						uni.showNavigationBarLoading();
						self.recursionCompressH5(filePath,function(img){
							console.log(img);
							console.log(self.currbase64);
							
						
							var newmysrc = self.currbase64;
							console.log(newmysrc);
							 var mysrc =newmysrc.toString().split(",")[1];
							console.log(mysrc);						
					
							let mydata={
								fileData: mysrc,
								contentType: 'image/png',
								fileName:"wj1.png",
							}
							self.requestfile_tool({
								 url: '/app/v1/fileOss/uploadByBaseData', // 你的上传API地址
								type:'POST',
								data:mydata,
								fileName:"wj1.png",
							}).then(uploadRes => {
								uni.hideNavigationBarLoading();
								self.uploadloding=false;
								if(uploadRes.data.code==2000){
									uni.hideNavigationBarLoading();
									console.log('图片上传成功', uploadRes);
									let uploadResdata= uploadRes.data;
									console.log(uploadResdata);
									self.srcstring=uploadResdata.data;
								
								}else{
									uni.hideNavigationBarLoading();
									self.uploadloding=false;
									uni.showModal({
									  title: '上传失败',
									  content:uploadRes.data.msg,
									  showCancel: false
									});
									
								}
							}).catch(err => {
								uni.hideNavigationBarLoading();
								self.uploadloding=false;
							  console.error(err);
							  
							});
							
						});
						
							
							/*
							this.images = res.tempFilePaths;
							const mysrc = res.tempFilePaths[0];
							console.log(mysrc);
							if(self.isrequest){
							const tempFilePaths = res.tempFilePaths;
								
							const header={
								'Content-Type':'application/json',
								Authorization: uni.getStorageSync("authorization")
							};
								console.log(tempFilePaths[0]);
							uni.uploadFile({
							  url: uni.getStorageSync("localurl")+'/app/v1/fileOss/upload', // 你的上传API地址
							  filePath: tempFilePaths[0],
							  name: 'file',
							header: header, // 设置请求的 header
							  formData: {
								// 其他要上传的参数
								file:{}
							  },
							  success: (uploadRes) => {
								console.log('图片上传成功', uploadRes);									
								let uploadResdata= JSON.parse(uploadRes.data);
								console.log(uploadResdata);
								self.srcstring=uploadResdata.data;
								
								
									*/
							  }
							  ,fail: function (err) {
							  	// 处理错误情况
								self.uploadloding=false;
							  	console.log('err:', err);
							    },
							    complete: function () {
							  	// 不管成功失败都会执行的函数
							  	self.uploadloding=false;
							  	console.log('chooseImage complete');
							    }
							});
						setTimeout(() => {
							     self.uploadloding=false;
							    }, 1500); // 延迟2秒执行
					
						
					
			},
			recursionCompressH5(url, callback) {
				
			if (typeof url === 'string') {
					this.getUserImageCompressH5(url,callback)
				} else if (typeof url === 'object') {
					for (let itemImg of url) {
						this.getUserImageCompressH5(itemImg,callback)
					}
				}
			},
			// h5压缩图片
			getUserImageCompressH5 (imgUrl,callback) {
				let that = this;
				return new Promise((resolve, reject)=>{
					uni.getImageInfo({
						src: imgUrl,
						success(res) {
							let canvasWidth = res.width; //图片原始长宽
							let canvasHeight = res.height;
							let img = new Image();
							img.src = res.path;							
							let canvas = document.createElement("canvas");
							let ctx = canvas.getContext("2d");
							canvas.width = canvasWidth / 2;
							canvas.height = canvasHeight / 2;
							ctx.drawImage(img, 0, 0, canvasWidth / 2, canvasHeight / 2);
							canvas.toBlob(function(fileSrc) {
								let imgSrc = window.URL.createObjectURL(fileSrc);
								uni.getFileInfo({
									filePath: imgSrc,
									success: (resFileInfo) => {
										if (resFileInfo.size > 600000) {
											//压缩后大于1M就继续压缩
											that.recursionCompressH5(imgSrc, callback);
											return;
										} else {
											let resultBase64 = canvas.toDataURL("image/png");
											that.currbase64=resultBase64;
											resolve(imgSrc)
											//that.tempImageList.push(imgSrc);
											console.log("地址:"+resFileInfo.path);
											callback && callback(imgSrc)
										}
									},	
								});
							});
						}
					});
				})
			},	
			onDescKeyInput: function(event) {
				self = this;
				if(event.target.value!=""){
					/*
					statuArray: ['正常', '异常','盘盈'],
					statuResultArray: ['位置异常','使用人异常'],
					statuindex:0,
					statuResultindex:0,
					*/
				   console.log(111);
				   self.statuindex=1;
				   self.statuResultindex=1;
				   if(self.assetDescription.indexOf("使用人异常")==-1){
					   self.assetDescription="使用人异常"+self.assetDescription;
				   }
				}else{
					if(self.model.checkPosition==self.CurrentStoreId){
						self.statuindex=0;
						self.statuResultindex=0;
						 self.assetDescription=self.assetDescription.replace("使用人异常","");
					}else{
						self.statuResultindex=0;
						 self.assetDescription=self.assetDescription.replace("使用人异常","");
					}
				}
				
			},
			isanAsset(e){
				//console.log(e.currentTarget.dataset.id);
				console.log(112222);
				uni.navigateTo({
					url: '../asset/asset?Id=' + e.currentTarget.dataset.id,
				});
			},
			getTime: function() {
			
				var date = new Date(),
					year = date.getFullYear(),
					month = date.getMonth() + 1,
					day = date.getDate(),
					hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
					minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
					second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				month >= 1 && month <= 9 ? (month = "0" + month) : "";
				day >= 0 && day <= 9 ? (day = "0" + day) : "";
				var timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
				return timer;
			},
			getDateDay(){
				var myDate = new Date();            
				 
				var year=myDate.getFullYear();        //获取当前年
				var month=myDate.getMonth()+1;   //获取当前月
				var date=myDate.getDate();            //获取当前日
				 
				 
				var now=year+''+this.getNow(month)+""+this.getNow(date);
				return now;
				},
				getDateDayStr(Str) {
					console.log(Str);
					if(Str.indexOf("-")==-1){
						return Str.substr(0,4)+"-"+Str.substr(4,2)+"-"+Str.substr(6,2);
					}else{
						return Str;
					}
				},
				getNow(s){
					return s < 10 ? '0' + s: s;
					},
			bindPickerChange: function(e) {
				console.log(111);
			            this.statuindex = e.target.value
			        },

			stockallimg() {
				const newDocumentId = uni.getStorageSync('DocumentId');
				const newAssetCode = uni.getStorageSync('AssetCode');
				self = this;
				
				// 只允许通过相机扫码
				uni.chooseImage({
					count: 1,
					sizeType: ['original', 'compressed'],
					sourceType: ['camera'],
					success: function(res) {
						// 预览图片
						this.images = res.tempFilePaths;
						const mysrc = res.tempFilePaths[0];
						self.srcstring = mysrc;
						console.log("img_"+newAssetCode);
						console.log(mysrc);
						uni.setStorage({
							key: "img_"+newAssetCode,
							data: mysrc
						});
					}
				});
			},
			signscanCode(){
				self = this;
				uni.scanCode({
					onlyFromCamera: true,
					success: function(qrres) {
						//var mymodel = JSON.parse(qrres.result);
						console.log(qrres.result);
						const myDocumentId = uni.getStorageSync('DocumentId');
						
						var sql='select * from buildDetailTable where 盘点单编码="'+myDocumentId+'" and 资产编码="'+qrres.result+'"';
						console.log(sql);
						executeSQL('nfc',sql, res => {
							console.log(res.length);
								if(res.length==0){
									uni.showToast({
										icon: 'none',
										title: '扫描资产不在盘点单内'
									});
									}else{
										console.log(this.optiontype=="1");
										if(this.optiontype=="1"){
											self.model = res[0];
											self.assetCode=self.model.资产编码;
											self.assetCodeTitle=self.model.资产编码;
											console.log(res[0]);
											if(res[0].ImgUrl!=""){
												self.scrbt=res[0].ImgUrl;
											}
										}else{
											self.assetCode=res[0].资产编码;
											self.assetCodeTitle=res[0].资产编码;
										}
										console.log(self.assetCode);
									}
							})
						
						}
				});
				},
				confirm(str) {
					var _this = this;
					self = this;
					_this.auiDialog.title = '系统提示';
					_this.auiDialog.msg = str;
					_this.auiDialog.items = [];
					_this.auiDialog.btns = [{
							name: '取消'
						},
						{
							name: '确定'
						}
				
					];
					
					
					_this.$refs.dialog.show();
				},
				openWin(url, opts) {
					aui.openWin(url, opts)
				},
				closeWin() {
					aui.closeWin();
				},
				//dialog弹窗底部按钮回调
				dialogCallback(e) {
					self = this;
					var _this = this;
					console.log(e);
					if (_this.$refs.dialog.getVal().length > 0) { //prompt输入框——点击确定时弹出输入内容
						_this.auiDialog.title = '提示';
						_this.$refs.dialog.getVal().forEach(function(item, index) {
							_this.auiDialog.msg += '<div style="display: flex;">' + item.label + '：' + item.value +
								'</div>';
						});
						_this.auiDialog.btns = [{
							name: '确定',
							color: '#197DE0'
						}];
						_this.auiDialog.items = [];
						_this.auiDialog.theme = 1;
						_this.$refs.dialog.show();
					}
					if (e.msg == "确定") {
						console.log(self.currId);
					
						try {						
							//assetUsingName
							var updateSQL = 'update buildDetailTable set 盘点位置="'+self.CurrentStoreName+'",PdStorePlaceId="'+self.my_newDataObj['StoreId']+'",盘点人="'+self.loginName+'",盘点日期="'+self.my_newDataObj['盘点日期']+'",盘点状态= "已盘",盘点结果="'+self.my_newDataObj['盘点结果']+'",盘点备注="'+self.my_newDataObj['盘点备注信息']+'",盘点使用人="'+self.my_newDataObj['盘点使用人']+'" where 资产编码 ="'+self.model['资产编码']+'" and DocumentId="'+self.mynewDocumentId+'"';  
							console.log(updateSQL);  
							executeSQL('nfc', updateSQL, res => {  
								console.log("已更新明细数据")  
							})
							var updateSQL = 'update MybuildTable set StockCheckResult="1" where Id="'+self.mynewDocumentId+'"';
							console.log(updateSQL);  
							executeSQL('nfc', updateSQL, res => {  
								console.log("更新列表数据");
								uni.navigateBack({
								
								});
							})
							if(this.curroldpdjg!=self.my_newDataObj['盘点结果']){
								var daipanshul=parseInt(this.documentmodel.未盘);
								var ypshul=parseInt(this.documentmodel.正常);
								var ycshul=parseInt(this.documentmodel.异常);
								var ykshul=parseInt(this.documentmodel.盘亏);
								console.log(this.curroldpdjg);
								if(this.curroldpdjg=="未盘"){
									if(daipanshul>0){
									daipanshul=daipanshul-1;
									}else{
										ykshul=ykshul-1;
									}
									
								}
								if(this.curroldpdjg=="正常"){
									ypshul=ypshul-1;
								}
								if(this.curroldpdjg=="异常"){
									ycshul=ycshul-1;
								}
								if(this.curroldpdjg=="盘亏"){
									ykshul=ykshul-1;
								}
								
								if(self.my_newDataObj['盘点结果']=="未盘"){
									daipanshul=daipanshul+1;
								}
								if(self.my_newDataObj['盘点结果']=="正常"){
									ypshul=ypshul+1;
								}
								if(self.my_newDataObj['盘点结果']=="异常"){
									ycshul=ycshul+1;
								}
								if(self.my_newDataObj['盘点结果']=="盘亏"){
									ykshul=ykshul+1;
								}
								
								var updateSQL = 'update MybuildTable set StockCheckResult="1",未盘="'+daipanshul+'",正常="'+ypshul+'",异常="'+ycshul+'",盘亏="'+ykshul+'" where Id="'+self.mynewDocumentId+'"';
									console.log(updateSQL);  
									executeSQL('nfc', updateSQL, res => {  
										console.log("已更新列表数据");
										uni.setStorage({
											key: 'documentRefresh',
											data: '1'
										});
										uni.setStorageSync("pdsys","1");
										uni.navigateTo({
											url: '../stock/StockDocumentDetail?id=' + self.mynewDocumentId,
											animationType:'slide-in-left',
												animationDuration: 500
										});		
									})
								
							}else{								
							uni.setStorageSync("pdsys","1");
							uni.navigateTo({
								url: '../stock/StockDocumentDetail?id=' + self.mynewDocumentId,
								animationType: 'slide-in-left',
								animationDuration: 500
							});
							}
										//this.model = res.data.model;
									
								
				
						} catch (e) {
				
						}
				
					}
				
				},
				
				request_tool(options){
				 // 在这里可以对请求头进行一些设置
				 let baseUrl = uni.getStorageSync("localurl"); 
				 let userInfo = uni.getStorageSync("userInfo");
				 if (userInfo) {
				 	options.data['userLevelCode'] =JSON.parse(userInfo).levelCode;
				 	options.data['loginUserId'] = JSON.parse(userInfo).id;
				 }
				 let userDept = uni.getStorageSync("userDept");
				 console.log(userDept);
				 if (userDept) {
				 	options.data['loginUserDeptLevelCode'] = userDept.levelCode;
				 	options.data['loginUserDeptId'] = userDept.id;
				 }
				 let currentRole = uni.getStorageSync("userRoles");
				  console.log(currentRole);
				 if (currentRole) {
				 	options.data['roleLevelCode'] = currentRole[0].levelCode;
				 	options.data['roleId'] = currentRole[0].id;
				 }
	
				  options.header = {
				      'Content-Type':'application/json',
				      Authorization: uni.getStorageSync("authorization")
				 }
				
				    return new Promise((resolve, reject) => {
				        uni.request({
				            url: baseUrl + options.url || '',
				            method: options.type || 'POST',
				            data: options.data || {},
				            header: options.header || {}      
				        }).then(data => {
				            let [err, res] = data;
							if(res.data.code==5001 || res.data.code==5002 ||
							res.data.code==5003 || res.data.code==5004){
								uni.removeStorageSync("LoginName");
								uni.removeStorageSync("userInfo");
								uni.removeStorageSync("authorization");
								uni.removeStorageSync("userToken")
								uni.removeStorageSync("userRoles");
								uni.removeStorageSync("userDept");
								uni.removeStorageSync("userReadDeptIds");
								uni.removeStorageSync("managePositionIds");
								uni.removeStorageSync("ASSETCODE");
								uni.navigateTo({
									url: '../login/login',
								});
							}
				            resolve(res);
				        }).catch(error => {
				            reject(error)
				        })
				    });
				},
			requestfile_tool(options){
			 // 在这里可以对请求头进行一些设置
			 let baseUrl = uni.getStorageSync("localurl"); 
			 options.header = {
			      'Content-Type':'application/json',
			      Authorization: uni.getStorageSync("authorization")
			 }
			console.log(options);
			    return new Promise((resolve, reject) => {
			        uni.request({
			            url: baseUrl + options.url || '',
			            method: options.type || 'POST',
			            data: options.data || {},
			            header: options.header || {}      
			        }).then(data => {
			            let [err, res] = data;     
						if(res.data.code==5001 || res.data.code==5002 ||
						res.data.code==5003 || res.data.code==5004){
							uni.removeStorageSync("LoginName");
							uni.removeStorageSync("userInfo");
							uni.removeStorageSync("authorization");
							uni.removeStorageSync("userToken")
							uni.removeStorageSync("userRoles");
							uni.removeStorageSync("userDept");
							uni.removeStorageSync("userReadDeptIds");
							uni.removeStorageSync("managePositionIds");
							uni.removeStorageSync("ASSETCODE");
							uni.navigateTo({
								url: '../login/login',
							});
						}
			            resolve(res);
			        }).catch(error => {
			            reject(error)
			        })
			    });
			},
			
			
			requeststo_tool(options){
			 // 在这里可以对请求头进行一些设置
			 let baseUrl = uni.getStorageSync("localurl");
			 			
			  options.header = {
			      'Content-Type':'application/json',
			      Authorization: uni.getStorageSync("authorization")
			 }
			 			
			    return new Promise((resolve, reject) => {
			        uni.request({
			            url: baseUrl + options.url || '',
			            method: options.type || 'POST',
			            data: options.data || {},
			            header: options.header || {}      
			        }).then(data => {
			            let [err, res] = data;        
			            resolve(res);
			        }).catch(error => {
			            reject(error)
			        })
			    });
			}
				

		}
			
	}
</script>

<style>
	.item-icon-bt{
		width: 30upx;
		height: 30upx;
	}
	.item-icon-sys {
		width: 40upx;
		height: 40upx;
	}
	.item-icon {
		width: 100upx;
		height: 100upx;
	}

	.Item {
		border-radius: 16rpx;
		background: #fff;
	}

	.item-text {
		border-bottom: 1px solid #e6e6e6;
		margin-right:  .8rem;
margin-left:  .8rem;
	}

	.item-text .span {
		display: inline-block;
		width: 50%;
		float: right;
		margin-bottom: 10rpx;
		text-align: right;
		
	}

	.item-text .ispan {
		font-style: normal;
		width: 43%;
		display: inline-block;
		margin-bottom: 10rpx;
		color: #9E9CA5;
	}
	
	.Item input{
		color: #BEBEBE;
		font-size:30rpx;
	}
　　.inputff{
		color: #BEBEBE;
		font-size:30rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

　　

	.item-content {
		padding-left: 0;
	}

	.item-title .ispan {
		font-size: 30rpx;
		width: auto;
		height: auto;
	}
	
	.item-title {
		font-size: 30rpx;
		color: #454545;
		width: 50%;
		height: 80rpx;
		line-height: 80rpx;
		margin-left: 30rpx;
	}
	
	.item-title-row {
		background-image: none;
		margin-right: .8rem;
		border-bottom: 1px solid #e6e6e6;
		background-color: #F4F5F6;
		margin-left: .8rem;
	}
	

	.item-link .item-inner {
		padding-right: 0;

	}

	.page-content {
		padding-top: 0;
	}

	.item-text {
		font-size: 30rpx;
		color: #454545;
		padding: 20rpx 0;
		padding-left: 0rpx;
		line-height: 1.2;
	}

	.btext {
		font-weight: normal;
		color: #F79D63;
	}

	.scroll-view_H {
		white-space: nowrap;

		.scroll-view-item_H {
			display: inline-block;
			width: 100%;
			height: 100px;
		}

		.uni-bg-red {
			background: red;
		}

		.uni-bg-green {
			background: green;
		}

		.uni-bg-blue {
			background: blue;
		}
	}

	.yp-Item-span {
		position: absolute;
		width: 50rpx;
		background-color: #BEBEBE;
		font-size: 25rpx;
		padding: 0 10rpx;
		margin-right: 10rpx;
		text-align: center;
		margin-left: 35rpx;
		margin-top: 24rpx;
		color:#FFFFFF;
		border-radius:8rpx;
	}
	.wp-Item-span {
		position: absolute;
		width: 50rpx;
		background-color: #6D8AF9;
		font-size: 25rpx;
		padding: 0 10rpx;
		margin-right: 10rpx;
		text-align: center;
		margin-left: 35rpx;
		margin-top: 24rpx;
		color:#FFFFFF;
		border-radius:8rpx;
	}
</style>